package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqMarketdetail;
import com.drug.mingkang.Mapper.HqMarketdetailMapper;
import com.drug.mingkang.service.HqMarketdetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 总公司销售明细(HqMarketdetail)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:43
 */
@Service("hqMarketdetailService")
public class HqMarketdetailServiceImpl implements HqMarketdetailService {
    @Resource
    private HqMarketdetailMapper hqMarketdetailMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param marketdetailId 主键
     * @return 实例对象
     */
    @Override
    public HqMarketdetail queryById(String marketdetailId) {
        return this.hqMarketdetailMapper.queryById(marketdetailId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqMarketdetail> queryAllByLimit(int offset, int limit) {
        return this.hqMarketdetailMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param hqMarketdetail 实例对象
     * @return 实例对象
     */
    @Override
    public HqMarketdetail insert(HqMarketdetail hqMarketdetail) {
        this.hqMarketdetailMapper.insert(hqMarketdetail);
        return hqMarketdetail;
    }

    /**
     * 修改数据
     *
     * @param hqMarketdetail 实例对象
     * @return 实例对象
     */
    @Override
    public HqMarketdetail update(HqMarketdetail hqMarketdetail) {
        this.hqMarketdetailMapper.update(hqMarketdetail);
        return this.queryById(hqMarketdetail.getMarketdetailId());
    }

    /**
     * 通过主键删除数据
     *
     * @param marketdetailId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String marketdetailId) {
        return this.hqMarketdetailMapper.deleteById(marketdetailId) > 0;
    }
}